﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml;

/// <summary>
/// Summary description for imsresource
/// </summary>
public class imsresource
{
    public string identifier = "";
    public string type = "";
    public string href = "";

    public string adlcp_scormtype = "";

    public List<string> lstFiles = new List<string>();


    /// <summary>
    /// this function will build the resource object form the node
    /// </summary>
    /// <param name="xn">the node which name is resource</param>
    /// <returns>a resource object contains values</returns>
    public  static imsresource getResourceFromNode(XmlNode xn)
    {
        imsresource imsRet = new imsresource();

        if (xn.Attributes["adlcp:scormtype"] != null)
            imsRet.adlcp_scormtype = xn.Attributes["adlcp:scormtype"].Value;

        if (xn.Attributes["identifier"] != null)
            imsRet.identifier = xn.Attributes["identifier"].Value;

        if (xn.Attributes["type"] != null)
            imsRet.type = xn.Attributes["type"].Value;

        if (xn.Attributes["href"] != null)
            imsRet.href = xn.Attributes["href"].Value;

        foreach (XmlNode obj in xn.ChildNodes)
        {
            if (obj.Name.ToLower() == "file")
            {
                if (obj.Attributes["href"] != null)
                {
                    imsRet.lstFiles.Add(obj.Attributes["href"].Value);
                }
            }
        }



        return imsRet;
    }


	public imsresource()
	{
		//
		// TODO: Add constructor logic here
		//
	}
}